package com.beibojd.service.impl;

import com.beibojd.dao.GoodsMapper;
import com.beibojd.pojo.Goods;
import com.beibojd.pojo.Result;
import com.beibojd.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 洪耀荣
 * @Date: 2021-06-25 19:40:29
 */
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    /**
     * 查询全部功能，要直接将数据给到html去所以直接返回list
     * @return
     */
    @Override
    public List<Goods> selectAllGoods() {
        return goodsMapper.selectAll();
    }

    @Override
    public void update(Goods goods) {
        goodsMapper.updateByPrimaryKey(goods);
    }

    @Override
    public Goods selectById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }

    @Override
    public Result addGoods(Goods goods) {
        goodsMapper.insert(goods);
        return new Result("添加成功");
    }

    @Override
    public Result sellGoods(Goods goods) {
        return null;
    }

    @Override
    public Result delgood(Integer customerId) {
        goodsMapper.deleteByPrimaryKey(customerId);
        return new Result("删除成功");
    }
}
